1
|
|
|
import { Column, PrimaryGeneratedColumn } from 'typeorm'; |
2
|
|
|
|
3
|
|
|
export enum Status { |
4
|
|
|
PRIVATE = 'private', |
5
|
|
|
PUBLIC = 'public' |
6
|
|
|
} |
7
|
|
|
|
8
|
|
|
export enum Type { |
9
|
|
|
KINDERGARTEN = 'kindergarten', |
10
|
|
|
PRIMARY = 'primary', |
11
|
|
|
ELEMENTARY = 'elementary', |
12
|
|
|
MIDDLE_SCHOOL = 'middle_school', |
13
|
|
|
HIGH_SCHOOL = 'high_school', |
14
|
|
|
} |
15
|
|
|
|
16
|
|
|
export abstract class AbstractSchool { |
17
|
|
|
@PrimaryGeneratedColumn('uuid') |
18
|
|
|
protected id: string; |
19
|
|
|
|
20
|
|
|
@Column({ type: 'varchar', nullable: false }) |
21
|
|
|
protected reference: string; |
22
|
|
|
|
23
|
|
|
@Column({ type: 'varchar', nullable: false }) |
24
|
|
|
protected name: string; |
25
|
|
|
|
26
|
|
|
@Column({ type: 'varchar', nullable: false }) |
27
|
|
|
protected address: string; |
28
|
|
|
|
29
|
|
|
@Column({ type: 'varchar', nullable: false }) |
30
|
|
|
protected zipCode: string; |
31
|
|
|
|
32
|
|
|
@Column({ type: 'varchar', nullable: false }) |
33
|
|
|
protected city: string; |
34
|
|
|
|
35
|
|
|
@Column('enum', { enum: Status, nullable: false }) |
36
|
|
|
protected status: Status; |
37
|
|
|
|
38
|
|
|
@Column('enum', { enum: Type, nullable: false }) |
39
|
|
|
protected type: Type; |
40
|
|
|
|
41
|
|
|
@Column({ type: 'varchar', nullable: true }) |
42
|
|
|
protected phoneNumber: string; |
43
|
|
|
|
44
|
|
|
@Column({ type: 'varchar', nullable: true }) |
45
|
|
|
protected email: string; |
46
|
|
|
|
47
|
|
|
@Column({ type: 'integer', nullable: true, default: 0 }) |
48
|
|
|
protected numberOfStudents: number; |
49
|
|
|
|
50
|
|
|
@Column({ type: 'integer', nullable: true, default: 0 }) |
51
|
|
|
protected numberOfClasses: number; |
52
|
|
|
|
53
|
|
|
@Column({ type: 'timestamp', default: () => 'CURRENT_TIMESTAMP' }) |
54
|
|
|
protected createdAt: number; |
55
|
|
|
|
56
|
|
|
constructor( |
57
|
|
|
reference: string, |
58
|
|
|
name: string, |
59
|
|
|
address: string, |
60
|
|
|
zipCode: string, |
61
|
|
|
city: string, |
62
|
|
|
status: Status, |
63
|
|
|
type: Type, |
64
|
|
|
phoneNumber?: string, |
65
|
|
|
email?: string, |
66
|
|
|
numberOfStudents?: number, |
67
|
|
|
numberOfClasses?: number |
68
|
|
|
) { |
69
|
|
|
this.reference = reference; |
70
|
|
|
this.name = name; |
71
|
|
|
this.address = address; |
72
|
|
|
this.zipCode = zipCode; |
73
|
|
|
this.city = city; |
74
|
|
|
this.status = status; |
75
|
|
|
this.type = type; |
76
|
|
|
this.phoneNumber = phoneNumber; |
77
|
|
|
this.email = email; |
78
|
|
|
this.numberOfStudents = numberOfStudents; |
79
|
|
|
this.numberOfClasses = numberOfClasses; |
80
|
|
|
} |
81
|
|
|
|
82
|
|
|
public getId(): string { |
83
|
|
|
return this.id; |
84
|
|
|
} |
85
|
|
|
|
86
|
|
|
public getReference(): string { |
87
|
|
|
return this.reference; |
88
|
|
|
} |
89
|
|
|
|
90
|
|
|
public getName(): string { |
91
|
|
|
return this.name; |
92
|
|
|
} |
93
|
|
|
|
94
|
|
|
public getZipCode(): string { |
95
|
|
|
return this.zipCode; |
96
|
|
|
} |
97
|
|
|
|
98
|
|
|
public getAddress(): string { |
99
|
|
|
return this.address; |
100
|
|
|
} |
101
|
|
|
|
102
|
|
|
public getCity(): string { |
103
|
|
|
return this.city; |
104
|
|
|
} |
105
|
|
|
|
106
|
|
|
public getStatus(): Status { |
107
|
|
|
return this.status; |
108
|
|
|
} |
109
|
|
|
|
110
|
|
|
public getType(): Type { |
111
|
|
|
return this.type; |
112
|
|
|
} |
113
|
|
|
|
114
|
|
|
public getPhoneNumber(): string { |
115
|
|
|
return this.phoneNumber; |
116
|
|
|
} |
117
|
|
|
|
118
|
|
|
public getNumberOfStudents(): number { |
119
|
|
|
return this.numberOfStudents; |
120
|
|
|
} |
121
|
|
|
|
122
|
|
|
public getNumberOfClasses(): number { |
123
|
|
|
return this.numberOfClasses; |
124
|
|
|
} |
125
|
|
|
|
126
|
|
|
public getEmail(): string { |
127
|
|
|
return this.email; |
128
|
|
|
} |
129
|
|
|
|
130
|
|
|
public getCreatedAt(): number { |
131
|
|
|
return this.createdAt; |
132
|
|
|
} |
133
|
|
|
|
134
|
|
|
protected baseUpdate( |
135
|
|
|
reference: string, |
136
|
|
|
name: string, |
137
|
|
|
address: string, |
138
|
|
|
zipCode: string, |
139
|
|
|
city: string, |
140
|
|
|
status: Status, |
141
|
|
|
type: Type, |
142
|
|
|
email?: string, |
143
|
|
|
phoneNumber?: string, |
144
|
|
|
numberOfStudents?: number, |
145
|
|
|
numberOfClasses?: number |
146
|
|
|
) { |
147
|
|
|
this.reference = reference; |
148
|
|
|
this.name = name; |
149
|
|
|
this.address = address; |
150
|
|
|
this.zipCode = zipCode; |
151
|
|
|
this.city = city; |
152
|
|
|
this.status = status; |
153
|
|
|
this.type = type; |
154
|
|
|
this.email = email; |
155
|
|
|
this.phoneNumber = phoneNumber; |
156
|
|
|
this.numberOfStudents = numberOfStudents; |
157
|
|
|
this.numberOfClasses = numberOfClasses; |
158
|
|
|
} |
159
|
|
|
} |
160
|
|
|
|